﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;

namespace Chaos.converters
{
    class booltoint : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value!=null && value is bool )  
            {  
                bool val = (bool)value;  
                return val ? 1 : 0;  
            }  
            return null;  
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {          
            if (value!=null && value is int )  
            {  
                int val = (int)value;  
                return (val==0) ? false : true;  
            }  
            return null;  
        }
    }
}
